package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Constants;
import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.dto.NurseLevelDTO;
import com.hksj.Intelligentmanagement.dto.NurseLevelWithNurseDTO;
import com.hksj.Intelligentmanagement.service.NurseLevelService;
import com.hksj.Intelligentmanagement.vo.NurseLevelVo;
import com.hksj.Intelligentmanagement.vo.NurseLevelWithNurseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "麻醉人员等级管理")
@RestController
@RequestMapping("/api/anesthesiaLevel")
public class AnesthesiaLevelController {
    @Autowired
    private NurseLevelService nurseLevelService;

    @ApiOperation("新增麻醉人员等级")
    @PostMapping("/createAnesthesiaLevel")
    public Rest createAnesthesiaLevel(@RequestBody @Validated(NurseLevelDTO.Create.class) NurseLevelDTO anesthesiaLevel){
        anesthesiaLevel.setType(Constants.TYPE_ANESTHESIA);
        return nurseLevelService.create(anesthesiaLevel);
    }

    @ApiOperation("修改麻醉人员等级")
    @PostMapping("/updateAnesthesiaLevel")
    public Rest updateAnesthesiaLevel(@RequestBody @Validated(NurseLevelDTO.Update.class) NurseLevelDTO anesthesiaLevel){
        return nurseLevelService.updateNurseLevel(anesthesiaLevel);
    }

    @ApiOperation("删除麻醉人员等级")
    @DeleteMapping("/deleteAnesthesiaLevel/{id}")
    public Rest deleteAnesthesiaLevel(@PathVariable("id") String id){
        return nurseLevelService.delete(id);
    }
    @ApiOperation("查询麻醉人员等级列表")
    @PostMapping("/listAnesthesiaLevel")
    public Rest<List<NurseLevelVo>> listAnesthesiaLevel(@RequestBody NurseLevelDTO anesthesiaLevel){
        anesthesiaLevel.setType(Constants.TYPE_ANESTHESIA);
        return Rest.ok(nurseLevelService.listNurseLevel(anesthesiaLevel));
    }

    @ApiOperation("查询麻醉人员等级列表和人员信息")
    @PostMapping("/listAnesthesiaLevelWithNurse")
    public Rest<List<NurseLevelWithNurseVo>> listAnesthesiaLevelWithNurse(@RequestBody NurseLevelWithNurseDTO levelWithNurse){
        levelWithNurse.setType(Constants.TYPE_ANESTHESIA);
        return Rest.ok(nurseLevelService.listNurseLevelWithNurse(levelWithNurse));
    }
}
